package com.hongkzh.www.adv.controller;

import com.auth0.jwt.interfaces.Claim;
import com.google.common.collect.Lists;
import com.hongkzh.www.adv.service.AdvService;
import com.hongkzh.www.adv.service.CarouselService;
import com.hongkzh.www.adv.service.EnterpriseAdvService;
import com.hongkzh.www.adv.service.MediaService;
import com.hongkzh.www.conmon.BaseController;
import com.hongkzh.www.conmon.BusinessException;
import com.hongkzh.www.conmon.JwtUtil;
import com.hongkzh.www.conmon.ReqResponse;
import com.hongkzh.www.swagger.annotation.*;
import com.jfinal.aop.Clear;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;

import java.util.List;
import java.util.Map;

/**
 * @author martins
 */
@Api(tag = "mediaAdv", description = "自媒体广告")
public class MediaAdvController extends BaseController {
    MediaService mediaService = new MediaService();
    static CarouselService carouselService = new CarouselService();
  /*  @ApiOperation(url = "/v1/mediaAdv/getMainCarouselList", tag = "mediaAdv", httpMethod = "post",description = "获取自媒体主页轮播图列表")
    @ApiResponses({
            @ApiResponse(code=200,message="成功",responseHeaders={
                    @ResponseHeader(name="code",description = " 0成功 1失败"),
                    @ResponseHeader(name="data",description = "{ imgSrc 图片地址 ,imgLinks 图片链接 imgRank 图片排序 background 背景  id 视频广告id carouselId 轮播图id}"),
                    @ResponseHeader(name="msg",description = "失败原因") })

    })
    public void getMainCarouselList(){
        ReqResponse<List<Record>> r=new ReqResponse();
        List<Record>  record= mediaService.getCarouselList();
        r.setData(record);
        renderJson(r);
    }*/

    @ApiOperation(url = "/v1/mediaAdv/getMainAllCategoryList", tag = "mediaAdv", httpMethod = "post", description = "获取自媒体所有分类信息")

    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ imgSrc 图片地址 ,categoryId 分类id imgRank 图片排序 name 名称  }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void getMainAllCategoryList() {

        ReqResponse<List<Record>> r = new ReqResponse();
        List<Record> record = Lists.newArrayList();

        record = mediaService.AllCategoryList();


        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaAdv/getUserCategoryList", tag = "mediaAdv", httpMethod = "post", description = "获取自媒体用户分类信息")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "isFirst", description = " 完善信息  1为是 2为否 默认为空", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ imgSrc 图片地址 ,categoryId 分类id imgRank 图片排序 name 名称 , type 类型  1自媒体 2企业广告3城市广告4传统文化}"),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    @Clear
    public void getUserCategoryList() {
        String token = getPara("loginUid");
        String loginUid = "";
        if (StrKit.notBlank(token)) {
            Map<String, Claim> map = JwtUtil.unsign(token);
            loginUid = map.get("user_id").asString();
        }

        String isFirst = getPara("isFirst");
        ReqResponse<List<Record>> r = new ReqResponse();
        List<Record> record = mediaService.getUserCategoryList(loginUid, isFirst);

        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaAdv/addUserCategory", tag = "mediaAdv", httpMethod = "post", description = "增加自媒体用户分类信息")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "categoryId", description = "数组", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void addUserCategory() {
        String loginUid = getAttr("loginUid");
        String[] category = getParaValues("categoryId");
        ReqResponse<String> r = new ReqResponse();

        try {
            if (null != category && category.length > 0) {
                MediaService mediaService2 = enhance(MediaService.class);
                mediaService2.addUserCategory(loginUid, category);
            }
        } catch (Exception e) {
            e.printStackTrace();
            r.setCode(1);
            r.setMsg("失败");
        }

        renderJson(r);
    }

/*
    @ApiOperation(url = "/v1/mediaAdv/getMainTop10List", tag = "mediaAdv", httpMethod = "post",description = "获取自媒体主页top10列表")
    @ApiResponses({
            @ApiResponse(code=200,message="成功",responseHeaders={
                    @ResponseHeader(name="code",description = " 0成功 1失败"),
                    @ResponseHeader(name="data",description = "{ coverImgSrc 图片地址 ,title 标题 , praiseCount 点赞总数 ,categoryName 分类名称  cityName 城市名称 , userId 用户id , id 视频id  }"),
                    @ResponseHeader(name="msg",description = "失败原因") })

    })
    public void getMainTop10List(){
        ReqResponse<List<Record>> r=new ReqResponse();
        List<Record>  record= mediaService.getTop10List();
        r.setData(record);
        renderJson(r);
    }*/


    /*
        @ApiOperation(url = "/v1/mediaAdv/getMainHotAdvList", tag = "mediaAdv", httpMethod = "post",description = "获取自媒体主页人气分页信息")

        @Params({
                @Param(name = "pageNumber", description = "页码", required = true, dataType = "string")
        })
        @ApiResponses({
                @ApiResponse(code=200,message="成功",responseHeaders={
                        @ResponseHeader(name="code",description = " 0成功 1失败"),
                        @ResponseHeader(name="data",description = "totalRow 总行数  pageNumber第几页 firstPage 是否第一页 lastPage 是否最后一页 totalPage 总页数 pageSize每页条数  list[{   id 视频id coverImgSrc 图片地址   title 标题 categoryName 分类名称  praiseCount 点赞数 rewardCount 奖励数  cityName 城市名称   advType 1数据 2 广告 vedioLength 视频长度 type 类型  1自媒体 2企业广告3城市广告4传统文化 }]"),
                        @ResponseHeader(name="msg",description = "失败原因") })

        })
        public void getMainHotAdvList(){
            int pageNumber=getParaToInt("pageNumber");
            ReqResponse<Page<Record>> r=new ReqResponse();
            Page<Record> record= mediaService.getHotAdvList(pageNumber);
            r.setData(record);
            renderJson(r);
        }*/
   /* @ApiOperation(url = "/v1/mediaAdv/getMainNearbyAdvList", tag = "mediaAdv", httpMethod = "post",description = "获取自媒体主页附近分页信息")

    @Params({
            @Param(name = "latitude", description = "纬度", required = true, dataType = "string"),
            @Param(name = "longitude", description = "经度", required = true, dataType = "string"),
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="成功",responseHeaders={
                    @ResponseHeader(name="code",description = " 0成功 1失败"),
                    @ResponseHeader(name="data",description = "totalRow 总行数  pageNumber第几页 firstPage 是否第一页 lastPage 是否最后一页 totalPage 总页数 pageSize每页条数  list[{id 视频id coverImgSrc 图片地址 coverImgWidth封面宽 coverImgHeight封面高  title 标题 categoryName 分类名称  praiseCount 点赞数 rewardCount 奖励数    distance 距离   advType 1数据 2 广告 vedioLength 视频长度 type 类型  1自媒体 2企业广告3城市广告4传统文化  }]"),
                    @ResponseHeader(name="msg",description = "失败原因") })

    })
    public void getMainNearbyAdvList(){
        double latitude=Double.parseDouble(getPara("latitude"));
        double longitude=Double.parseDouble(getPara("longitude"));
        int pageNumber=getParaToInt("pageNumber");
        ReqResponse<Page<Record>> r=new ReqResponse();

        Page<Record> record= mediaService.getNearbyAdvList(latitude,longitude,pageNumber);
        r.setData(record);
        renderJson(r);
    }
*/
/*
    @ApiOperation(url = "/v1/mediaAdv/getCirclesList", tag = "mediaAdv", httpMethod = "post",description = "获取主页圈子列表")

    @ApiResponses({
            @ApiResponse(code=200,message="成功",responseHeaders={
                    @ResponseHeader(name="code",description = " 0成功 1失败"),
                    @ResponseHeader(name="data",description = " id  id name 名称 categoryId 分类id "),
                    @ResponseHeader(name="msg",description = "失败原因") })

    })
    public void getCirclesList(){
        ReqResponse<List<Record>> r=new ReqResponse();    ;

        r.setData(mediaService.getCirclesList());
        renderJson(r);
    }*/
    @ApiOperation(url = "/v1/mediaAdv/getCategoryCirclesList", tag = "mediaAdv", httpMethod = "post", description = "获取分类页圈子列表")
    @Params({
            @Param(name = "categoryId", description = "分类id", required = true, dataType = "string"),
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string"),
            @Param(name = "sortId", description = "排序字段 默认 成员最多 user_count  最新创建 create_date ", required = false, dataType = "string"),
            @Param(name = "sortValue", description = "排序值 asc 升 desc 降 ", required = false, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " circleId 圈子id  name 圈子名称 coverImgWidth封面宽 coverImgHeight封面高 coverImgSrc 封面图片 uid 用户id,headImg头像 ,uName 用户名称 userCount 圈子人数"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getCategoryCirclesList() {
        String categoryId = getPara("categoryId");
        int pageNumber = getParaToInt("pageNumber");
        String sortId = getPara("sortId");
        String sortValue = getPara("sortValue");
        if (StrKit.isBlank(sortId)) {
            sortId = "user_count";
        }
        if (StrKit.isBlank(sortValue)) {
            sortValue = "desc";
        }
        ReqResponse<Page<Record>> r = new ReqResponse();
        ;

        r.setData(mediaService.getCategoryCirclesList(categoryId, pageNumber, sortId, sortValue));
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaAdv/getMediaSearchCirclesList", tag = "mediaAdv", httpMethod = "post", description = "获取自媒体圈子筛选")
    @Params({
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string"),
            @Param(name = "categoryId", description = "分类id 空为全部", required = false, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " circleId 圈子id  name 圈子名称 coverImgWidth封面宽 coverImgHeight封面高 coverImgSrc 封面图片 uid 用户id,headImg头像 ,uName 用户名称 userCount 圈子人数"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getMediaSearchCirclesList() {
        int pageNumber = getParaToInt("pageNumber");
        String categoryId = getPara("categoryId");

        ReqResponse<Page<Record>> r = new ReqResponse();
        ;

        r.setData(mediaService.getMediaSearchCirclesList(pageNumber, categoryId));
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaAdv/getMediaCirclesList", tag = "mediaAdv", httpMethod = "post", description = "获取自媒体圈子列表")
    @Params({
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string"),
            @Param(name = "sortId", description = "排序字段 默认 成员最多 user_count  最新创建 create_date ", required = false, dataType = "string"),
            @Param(name = "sortValue", description = "排序值 asc 升 desc 降 ", required = false, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " circleId 圈子id  name 圈子名称 coverImgWidth封面宽 coverImgHeight封面高 coverImgSrc 封面图片 uid 用户id,headImg头像 ,uName 用户名称 userCount 圈子人数"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getMediaCirclesList() {
        int pageNumber = getParaToInt("pageNumber");
        String sortId = getPara("sortId");
        String sortValue = getPara("sortValue");
        if (StrKit.isBlank(sortId)) {
            sortId = "user_count";
        }
        if (StrKit.isBlank(sortValue)) {
            sortValue = "desc";
        }
        ReqResponse<Page<Record>> r = new ReqResponse();
        ;

        r.setData(mediaService.getMediaCirclesList(pageNumber, sortId, sortValue));
        renderJson(r);
    }


    @ApiOperation(url = "/v1/mediaAdv/getMediaTop10List", tag = "mediaAdv", httpMethod = "post", description = "获取自媒体top10 轮播图")
    @Params({

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ }"),
                    @ResponseHeader(name = "data", description = "{ " +
                            "carousels[imgSrc 图片地址 ,   id 视频id    title 标题 vedioLength  视频长度   type  1自媒体 2企业广告3城市广告4传统文化 ] " +
                            "top [coverImgSrc 图片地址 ,title 标题 , praiseCount 点赞总数 ,  uName 用户名称 ,headImg 用户头像 userId 用户id , id 视频id  categoryName 分类名称]}"),

                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getMediaTop10List() {
        ReqResponse<Record> r = new ReqResponse();
        List<Record> carousels = carouselService.getCarouselList("1");
        List<Record> top = mediaService.getMediaTop10List();
        Record record = new Record();
        record.set("carousels", carousels);
        record.set("top", top);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaAdv/getMainHotAdvList", tag = "mediaAdv", httpMethod = "post", description = "乐看-推荐-瀑布流-分页信息")
    @Params({

            @Param(name = "loginUid", description = "用戶id", required = true, dataType = "string"),
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "totalRow 总行数  pageNumber第几页 firstPage 是否第一页 lastPage 是否最后一页 totalPage 总页数 pageSize每页条数  list[{ uid 用户id,headImg头像 ,uName 用户名称  id 视频id coverImgSrc 图片地址   title 标题    praiseCount 点赞数 rewardCount 奖励数  cityName 城市名称 advType 1数据 2 广告 vedioLength 视频长度 type 类型  1自媒体 2企业广告3城市广告4传统文化  totalMoney 大于0 表示有红包}]"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    @Clear
    public void getMainHotAdvList() {
         String loginUid=getAttr("loginUid");
        int pageNumber = getParaToInt("pageNumber");
        ReqResponse<Page<Record>> r = new ReqResponse();
        Page<Record> record = mediaService.getMainHotAdvList(pageNumber,loginUid);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaAdv/getMediaHotAdvList", tag = "mediaAdv", httpMethod = "post", description = "获取自媒体 人气分页信息")
    @Params({


            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "totalRow 总行数  pageNumber第几页 firstPage 是否第一页 lastPage 是否最后一页 totalPage 总页数 pageSize每页条数  list[{ uid 用户id,headImg头像 ,uName 用户名称  id 视频id coverImgSrc 图片地址   title 标题    praiseCount 点赞数 rewardCount 奖励数  cityName 城市名称 advType 1数据 2 广告 vedioLength 视频长度 type 类型  1自媒体 2企业广告3城市广告4传统文化 getMediaHotAdvList 0 没有红包}]"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getMediaHotAdvList() {

        int pageNumber = getParaToInt("pageNumber");
        ReqResponse<Page<Record>> r = new ReqResponse();
        Page<Record> record = mediaService.getMediaHotAdvList(pageNumber);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaAdv/getMediaNearbyAdvList", tag = "mediaAdv", httpMethod = "post", description = "获取自媒体 附近分页信息")
    @Params({

            @Param(name = "latitude", description = "纬度", required = true, dataType = "string"),
            @Param(name = "longitude", description = "经度", required = true, dataType = "string"),
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "totalRow 总行数  pageNumber第几页 firstPage 是否第一页 lastPage 是否最后一页 totalPage 总页数 pageSize每页条数  list[{uid 用户id,headImg头像 ,uName 用户名称 id 视频id coverImgSrc 图片地址   title 标题   praiseCount 点赞数 rewardCount 奖励数    distance 距离  advType 1数据 2 广告 vedioLength 视频长度 type 类型  1自媒体 2企业广告3城市广告4传统文化}]"),

                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getMediaNearbyAdvList() {

        double latitude = Double.parseDouble(getPara("latitude"));
        double longitude = Double.parseDouble(getPara("longitude"));
        int pageNumber = getParaToInt("pageNumber");
        ReqResponse<Page<Record>> r = new ReqResponse();

        Page<Record> record = mediaService.getMediaNearbyAdvList(latitude, longitude, pageNumber);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaAdv/getCategoryCarouselList", tag = "mediaAdv", httpMethod = "post", description = "获取分类页轮播图列表")
    @Params({
            @Param(name = "categoryId", description = "分类id", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ imgSrc 图片地址 ,imgLinks 图片链接 imgRank 图片排序  id 视频广告id carouselId 轮播图id}"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getCategoryCarouselList() {
        String categoryId = getPara("categoryId");
        ReqResponse<List<Record>> r = new ReqResponse();
        r.setData(mediaService.getCategoryCarouselList(categoryId));
        renderJson(r);
    }


    @ApiOperation(url = "/v1/mediaAdv/getCategoryTop10List", tag = "mediaAdv", httpMethod = "post", description = "获取自媒体分类页top10列表")
    @Params({
            @Param(name = "categoryId", description = "分类id", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ coverImgSrc 图片地址 ,title 标题 , praiseCount 点赞总数 ,  uName 用户名称 ,headImg 用户头像 userId 用户id , id 视频id  }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getCategoryTop10List() {
        String categoryId = getPara("categoryId");
        ReqResponse<List<Record>> r = new ReqResponse();
        List<Record> record = mediaService.getCategoryTop10List(categoryId);
        r.setData(record);
        renderJson(r);
    }


    @ApiOperation(url = "/v1/mediaAdv/getCategoryHotAdvList", tag = "mediaAdv", httpMethod = "post", description = "获取自媒体分类页人气分页信息")
    @Params({
            @Param(name = "categoryId", description = "分类id", required = true, dataType = "string"),

            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "totalRow 总行数  pageNumber第几页 firstPage 是否第一页 lastPage 是否最后一页 totalPage 总页数 pageSize每页条数  list[{ uid 用户id,headImg头像 ,uName 用户名称  id 视频id coverImgSrc 图片地址   title 标题    praiseCount 点赞数 rewardCount 奖励数  cityName 城市名称 advType 1数据 2 广告 vedioLength 视频长度 type 类型  1自媒体 2企业广告3城市广告4传统文化 totalMoney 大于0 表示有红包 }]"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getCategoryHotAdvList() {
        String categoryId = getPara("categoryId");
        int pageNumber = getParaToInt("pageNumber");
        ReqResponse<Page<Record>> r = new ReqResponse();
        Page<Record> record = mediaService.getCategoryHotAdvList(pageNumber, categoryId);
        r.setData(record);
        renderJson(r);
    }


    @ApiOperation(url = "/v1/mediaAdv/getCategorySearchAdvList", tag = "mediaAdv", httpMethod = "post", description = "获取自媒体筛选分页信息")
    @Params({
            @Param(name = "categoryId", description = "分类id 空为全部", required = false, dataType = "string"),

            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "totalRow 总行数  pageNumber第几页 firstPage 是否第一页 lastPage 是否最后一页 totalPage 总页数 pageSize每页条数  list[{ uid 用户id,headImg头像 ,uName 用户名称  id 视频id coverImgSrc 图片地址   title 标题    praiseCount 点赞数 rewardCount 奖励数  cityName 城市名称 advType 1数据 2 广告 vedioLength 视频长度 type 类型  1自媒体 2企业广告3城市广告4传统文化  }]"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getCategorySearchAdvList() {
        String categoryId = getPara("categoryId");
        int pageNumber = getParaToInt("pageNumber");
        ReqResponse<Page<Record>> r = new ReqResponse();
        Page<Record> record = mediaService.getCategorySearchAdvList(pageNumber, categoryId);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaAdv/getCategoryNearbyAdvList", tag = "mediaAdv", httpMethod = "post", description = "获取自媒体分类页附近分页信息")
    @Params({
            @Param(name = "categoryId", description = "分类id", required = true, dataType = "string"),
            @Param(name = "latitude", description = "纬度", required = true, dataType = "string"),
            @Param(name = "longitude", description = "经度", required = true, dataType = "string"),
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "totalRow 总行数  pageNumber第几页 firstPage 是否第一页 lastPage 是否最后一页 totalPage 总页数 pageSize每页条数  list[{uid 用户id,headImg头像 ,uName 用户名称 id 视频id coverImgSrc 图片地址   title 标题   praiseCount 点赞数 rewardCount 奖励数    distance 距离  advType 1数据 2 广告 vedioLength 视频长度 type 类型  1自媒体 2企业广告3城市广告4传统文化 totalMoney 大于0 表示有红包 }]"),

                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getCategoryNearbyAdvList() {
        String categoryId = getPara("categoryId");
        double latitude = Double.parseDouble(getPara("latitude"));
        double longitude = Double.parseDouble(getPara("longitude"));
        int pageNumber = getParaToInt("pageNumber");
        ReqResponse<Page<Record>> r = new ReqResponse();

        Page<Record> record = mediaService.getCategoryNearbyAdvList(latitude, longitude, pageNumber, categoryId);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaAdv/getCategoryQuery", tag = "mediaAdv", httpMethod = "post", description = "筛选-自媒体分类页-查询配置")
    @Params({
            @Param(name = "categoryId", description = "分类id", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{  categoryId 分类id isCategoryQuery 启用分类查询 1是0否 regionalQuery 启用地区查询  1是0否 }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getCategoryQuery() {
        String categoryId = getPara("categoryId");
        ReqResponse<Record> r = new ReqResponse();
        Record record = mediaService.getCategoryQuery(categoryId);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaAdv/getCategoryQueryList", tag = "mediaAdv", httpMethod = "post", description = "筛选-结果")
    @Params({
            @Param(name = "categoryId", description = "分类id", required = false, dataType = "string"),
            @Param(name = "provinceId", description = "省份id", required = false, dataType = "string"),
            @Param(name = "loginUid", description = "当前登录用户id", required = true, dataType = "string"),
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "  totalRow 总行数  pageNumber第几页 firstPage 是否第一页 lastPage 是否最后一页 totalPage 总页数 pageSize每页条数  list[{id 视频id coverImgSrc 图片地址   title 标题   praiseCount 点赞数 rewardCount 奖励数    provinceName 省名称   uName用户名称 uid 用户id headImg 用户头像 type 类型  1自媒体 2企业广告3城市广告4传统文化} ] "),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getCategoryQueryList() {
        String categoryId = getPara("categoryId");
        String loginUid = getAttr("loginUid");
        String provinceId = getPara("provinceId");

        int pageNumber = getParaToInt("pageNumber");
        ReqResponse<Page<Record>> r = new ReqResponse();

        Page<Record> record = mediaService.getCategoryQueryList(categoryId, pageNumber, provinceId);
        r.setData(record);
        renderJson(r);
    }


    @ApiOperation(url = "/v1/mediaAdv/getMediaAdvAdvById", tag = "mediaAdv", httpMethod = "post", description = "获取自媒体广告视频信息")
    @Params({
            @Param(name = "loginUid", description = "当前登录用户id", required = true, dataType = "string"),
            @Param(name = "id", description = "视频id", required = true, dataType = "string"),
            @Param(name = "sourceType", description = "播放来源 1其他 2用户个人中心  ", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "  {  mediaType 0普通 1征婚  isRed 1是有红包 0没有" +
                            " playCount 播放总数 rewardCount 奖励总数 praiseCount 点赞总数 commentCount 评论数  collectionCount 收藏总数 " +
                            "collectionState 已经收藏 1   没收藏 0 praiseState 已经点赞 1  没点赞 0  " +
                            "cityName 城市名称 categoryName 分类名称 " +
                            "uid 用户id uName  用户名称 headImg 用户头像 sex性别 level级别 introduction 签名  introduce 介绍  address 地址age年龄 height 身高" +
                            " 详情集合infos[id 详情属性 name 详情值 ]" +
                            "albums用户相册[imgSrc图片地址]" +
                            " photographys 摄影图集[imgSrc图片地址]" +
                            "coverImgSrc 图片地址   imgSrc 视频地址 ,  title 标题 imgNote 详情内容  type 类型  1自媒体 2企业广告3城市广告4传统文化  " +
                            "createDate 创建时间  } " +
                            "tags[width 屏幕宽度 high  屏幕高度 tagId 标签id  type 标签类型 1圈子 2用户 3自定义  tagName 标签名称 x 标签x轴数  y 标签y轴数 orientation 标签方向0 左,1 右 ]" +
                            "products[productId 商品id title 标题 imgSrc图片 price 价格 num 数量]" +
                            "nextMediaAdvId 下一个视频id"  + "historyId 为空 用户未领取过红包 不为空 用户已领取" +
                            ""),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    @Clear
    public void getMediaAdvAdvById() {
        String sourceType = getPara("sourceType");
        String id = getPara("id");
        ReqResponse<Record> r = new ReqResponse();

        String token = getPara("loginUid");
        String loginUid = "";
        if (StrKit.notBlank(token)) {
            Map<String, Claim> map = JwtUtil.unsign(token);
            loginUid = map.get("user_id").asString();
        }
        try {
            Record record = mediaService.getAdvById(id, loginUid, sourceType);

            if (null != record) {

                r.setData(record);
            }
        } catch (BusinessException e) {
            r.setCode(1);
            r.setMsg(e.getErrMsg());
        }

        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaAdv/getRecruitById", tag = "mediaAdv", httpMethod = "post", description = "通过 招聘id 获取招聘信息 ")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "recruitId", description = "招聘id", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "data", description = " 总收藏数"),
                    @ResponseHeader(name = "code", description = "recruitId 招聘id salary薪资范围 title 标题 education学历 areaName区域名称 experience 经验introduce描述<web展示>  " +
                            " enterpriseId 企业id isAuth认证 1是0否  enterpriseName 公司名称 headImg 头像 address 企业地址  userId 用户id（聊天用） category所属分类 scale 规模listing上市状态 " +
                            "                             "
                    ),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })

    public void getRecruitById() {

        String loginUid = getAttr("loginUid");
        String recruitId = getPara("recruitId");
        ReqResponse<Record> r = new ReqResponse();
        try {
            r.setData(mediaService.getRecruitById(loginUid, recruitId));

        } catch (Exception e) {
            e.printStackTrace();
            r.setCode(1);
            r.setMsg("操作失败");
        }
        renderJson(r);
    }


    @ApiOperation(url = "/v1/mediaAdv/collection", tag = "mediaAdv", httpMethod = "post", description = "通过用户id   视频id  state收藏状态 1收藏0取消收藏")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "state", description = "收藏状态 1收藏0取消收藏", required = true, dataType = "string"),
            @Param(name = "id", description = "视频id", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "data", description = " 总收藏数"),
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })

    public void collection() {
        EnterpriseAdvService enterpriseAdvService2 = enhance(EnterpriseAdvService.class);
        String loginUid = getAttr("loginUid");
        String id = getPara("id");
        String state = getPara("state");
        ReqResponse<String> r = new ReqResponse();
        try {
            r.setData(enterpriseAdvService2.collection(loginUid, id, state));

        } catch (Exception e) {
            e.printStackTrace();
            r.setCode(1);
            r.setMsg("操作失败");
        }
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaAdv/praise", tag = "mediaAdv", httpMethod = "post", description = "通过用户id   视频id  state点赞状态 1点赞0取消点赞")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "state", description = "点赞状态 1点赞0取消点赞", required = true, dataType = "string"),
            @Param(name = "id", description = "视频id", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "data", description = " 总点赞数"),
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })

    public void praise() {
        EnterpriseAdvService enterpriseAdvService2 = enhance(EnterpriseAdvService.class);
        String loginUid = getAttr("loginUid");
        String id = getPara("id");
        String state = getPara("state");
        ReqResponse<String> r = new ReqResponse();
        try {
            r.setData(enterpriseAdvService2.praise(loginUid, id, state));
        } catch (Exception e) {
            e.printStackTrace();
            r.setCode(1);
            r.setMsg("操作失败");
        }
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaAdv/endPlayMediaAdvById", tag = "mediaAdv", httpMethod = "post", description = "播放完成给用户的积分")
    @Params({
            @Param(name = "id", description = "视频id", required = true, dataType = "string"),
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " type 0 啥也没有 1 红包 2积分 3物品"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void endPlayMediaAdvById() {
        AdvService advService2 = enhance(AdvService.class);
        String loginUid = getAttr("loginUid");
        String id = getPara("id");
        ReqResponse<Record> r = new ReqResponse();
        try {
            Record record = advService2.endPlayMediaAdvById(loginUid, id);

            r.setData(record);
        } catch (Exception e) {
            e.printStackTrace();
            r.setCode(1);

        }
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaAdv/getRedPacketsMediaAdvById", tag = "mediaAdv", httpMethod = "post", description = "打开红包")
    @Params({
            @Param(name = "id", description = "视频id", required = true, dataType = "string"),
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " money 获得红包数 "),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getRedPacketsMediaAdvById() {
        AdvService advService2 = enhance(AdvService.class);
        String loginUid = getAttr("loginUid");
        String id = getPara("id");
        ReqResponse<Record> r = new ReqResponse();
        try {
            Record record = advService2.getRedPacketsMediaAdvById(loginUid, id);

            r.setData(record);
        } catch (Exception e) {
            r.setCode(1);

        }
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaAdv/getUserInfo", tag = "mediaAdv", httpMethod = "post", description = "自媒体用户信息")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "id", description = "用户id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " uid 用户id  name 名称 friendId有值是好友 没值是陌生人 headImg 头像 level 级别 sex 1男2女 loginAddress 登录地址 loginTime 登录时间 introduction  签名  fans 粉丝数 " +
                            " 详情集合infos[id 详情属性 name 详情值 ] " +
                            " 标签 labels[id   name ] " +
                            "albums用户相册[imgSrc图片地址]" +
                            " 关注的人follows[uid  name名称  headImg 头像 ] followCounts 关注总数" +
                            " 圈子circles [circleId  circleName名称 coverImgSrc头像 categoryName 分类名称 circleCount 圈子人数  ]  circleCounts 圈子总数  " +
                            " 动态 dynamics[coverImgSrc ] dynamicCounts动态总数 "),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getUserInfo() {

        String loginUid = getAttr("loginUid");
        String id = getPara("id");
        ReqResponse<Record> r = new ReqResponse();
        try {
            Record record = mediaService.getUserInfo(loginUid, id);
            r.setData(record);
        } catch (Exception e) {
            e.printStackTrace();
            r.setCode(1);

        }
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaAdv/getUserMediasList", tag = "mediaAdv", httpMethod = "post", description = "个人中心 通过用户id 返回用户的自媒体列表")
    @Params({
            @Param(name = "uid", description = "用户id", required = true, dataType = "string"),
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string"),
            @Param(name = "sortId", description = "1时间最新 ", required = false, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "totalRow 总行数  pageNumber第几页 firstPage 是否第一页 lastPage 是否最后一页 totalPage 总页数 pageSize每页条数  list[name 名称 ,uid 用户id headImg 头像 introduction 简介 followUserId 自媒体或者企业id,fcount 关注总数]"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getUserMediasList() {

        String uid = getPara("uid");
        int pageNumber = getParaToInt("pageNumber");
        String sortId = getPara("sortId");
        ReqResponse<Page<Record>> r = new ReqResponse();
        Page<Record> record = mediaService.getUserMediasList(uid, pageNumber, sortId);

        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaAdv/getUserProductsList", tag = "mediaAdv", httpMethod = "post", description = "个人中心 通过用户id 返回用户的商品列表")
    @Params({
            @Param(name = "uid", description = "用户id", required = true, dataType = "string"),
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string"),
            @Param(name = "sortId", description = "1时间最新 ", required = false, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "totalRow 总行数  pageNumber第几页 firstPage 是否第一页 lastPage 是否最后一页 totalPage 总页数 pageSize每页条数  list[ productId 商品id title 标题 createDate 时间imgSrc图片 price 价格num 数量]"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getUserProductsList() {
        String uid = getPara("uid");

        int pageNumber = getParaToInt("pageNumber");
        String sortId = getPara("sortId");
        ReqResponse<Page<Record>> r = new ReqResponse();
        Page<Record> record = mediaService.getUserProductsList(uid, pageNumber, sortId);

        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaAdv/buyBooth", tag = "mediaAdv", httpMethod = "post", description = "自媒体购买展位")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            /*@Param(name = "id", description = "圈子id", required = true, dataType = "string"),*/
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " "),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void buyBooth() {
        String loginUid = getAttr("loginUid");

        ReqResponse<String> r = new ReqResponse();
        try {
            mediaService.buyBooth(loginUid);
        } catch (Exception e) {
            e.printStackTrace();
            r.setMsg("乐币不够");
            r.setCode(1);
        }
        renderJson(r);
    }


    @ApiOperation(url = "/v1/mediaAdv/searchHistory", tag = "mediaAdv", httpMethod = "post", description = "乐看搜索历史")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ hots 热搜索 [name] historys 搜索历史 [historyId name 名称] }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    @Clear
    public void searchHistory() {
        String token = getPara("loginUid");
        String loginUid = "";
        if (StrKit.notBlank(token)) {
            Map<String, Claim> map = JwtUtil.unsign(token);
            loginUid = map.get("user_id").asString();
        }
        ReqResponse<Record> r = new ReqResponse();
        Record record = mediaService.searchHistory(loginUid);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaAdv/deleteSearchHistory", tag = "mediaAdv", httpMethod = "post", description = "删除搜索历史")
    @Params({
            @Param(name = "historyId", description = "搜索历史id", required = true, dataType = "string"),
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{  }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void deleteSearchHistory() {
        String loginUid = getAttr("loginUid");
        String historyId = getPara("historyId");
        ReqResponse<Record> r = new ReqResponse();
        mediaService.deleteSearchHistory(loginUid, historyId);

        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaAdv/emptySearchHistory", tag = "mediaAdv", httpMethod = "post", description = "清空搜索历史")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{  }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void emptySearchHistory() {
        String loginUid = getAttr("loginUid");
        ReqResponse<Record> r = new ReqResponse();
        mediaService.emptySearchHistory(loginUid);

        renderJson(r);
    }


    @ApiOperation(url = "/v1/mediaAdv/searchMedia", tag = "mediaAdv", httpMethod = "post", description = "搜索自媒体-提示框")
    @Params({
            @Param(name = "name", description = "搜索内容", required = true, dataType = "string"),
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ title 名称 }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    @Clear
    public void searchMedia() {
        String token = getPara("loginUid");
        String loginUid = "";
        if (StrKit.notBlank(token)) {
            Map<String, Claim> map = JwtUtil.unsign(token);
            loginUid = map.get("user_id").asString();
        }
        String name = getPara("name");
        ReqResponse<List<Record>> r = new ReqResponse();
        r.setData(mediaService.searchMedia(loginUid, name));
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaAdv/searchMediaList", tag = "mediaAdv", httpMethod = "post", description = "乐看-搜索-自媒体列表")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "title", description = "内容", required = true, dataType = "string"),
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "totalRow 总行数  pageNumber第几页 firstPage 是否第一页 lastPage 是否最后一页 totalPage 总页数 pageSize每页条数  list[{ showType 1视频 2网页 categoryName 类别名称 coverImgSrc 图片地址 vedioLength  视频长度 lastIntegralCount 剩余积分  playCount播放总数 coverLink 图片链接  imgSrc 视频地址 ,imgLinks 视频链接 imgRank 图片排序 title 标题 imgNote 副标题 headImg 头像   uid 自媒体或者企业id uName 用户名称 playCount 播放总数 type 类型  1自媒体 2企业广告3城市广告4传统文化 utype 用户类型 1自媒体 2企业广告3城市广告4传统文化 id 视频id  staticAdv { coverImgSrc 图片地址 coverLink 图片链接  imgSrc 视频地址 ,imgLinks 视频链接 imgRank 图片排序 title 标题 imgNote 副标题 type 类型  1自媒体 2企业广告3城市广告4传统文化 }}]"),

                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    @Clear
    public void searchMediaList() {
        String title = getPara("title");
        int pageNumber = getParaToInt("pageNumber");
        String token = getPara("loginUid");
        String loginUid = "";
        if (StrKit.notBlank(token)) {
            Map<String, Claim> map = JwtUtil.unsign(token);
            loginUid = map.get("user_id").asString();
        }

        ReqResponse<Page<Record>> r = new ReqResponse();
        Page<Record> records = mediaService.searchMediaList(title, pageNumber);
        enhance(MediaService.class).saveSearch(loginUid, title);
        r.setData(records);
        renderJson(r);
    }

}
